#include<bits/stdc++.h>
using namespace std;
inline void read(int &x)
{
    x=0;int f=1;
    char c=getchar();
    for(;!isdigit(c);c=getchar())
    {
        if(c=='-')
        f=-1;
    }
    for(;isdigit(c);c=getchar())
    x=(x<<3)+(x<<1)+int(c)-48;
    x*=f;
}
const int N=1e6+10;
int T,n,m,t,cnt=0;
long long vm,v[N],a[N];
int d[N],p[N],wp[N];
bool del[N],sy[N];
double ex=1e-5;
struct node{
    double l,r;
    bool kbl,kbr;
}h[N];
bool cmp(node a,node b)
{
    if(a.l<b.l)
    return true;
    else
    {
        if(a.l==b.l)
        {
            if(a.kbl==1&&b.kbl==0)
            return true;
            else if(a.kbl==0&&b.kbl==1)
            return false;
            else
            {
                if(a.r<b.r)
                return true;
                else
                {
                    if(a.r==b.r)
                    {
                        if(a.kbl==0&&b.kbl==1)
                        return true;
                        else if(a.kbl==1&&b.kbl==0)
                        return false;
                        else
                        return true;
                    }
                    else
                    return false;
                }
            }
        }
    }
    return false;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while(T--)
    {
        for(int i=1;i<=n;i++)
        d[i]=v[i]=a[i]=p[i]=wp[i]=h[i].l=h[i].r=del[i]=sy[i]=0;
        cin>>n>>m>>t>>vm;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)
        read(wp[i]);
        int ans=0,cnt=0;
        for(int i=1;i<=n;i++)
        {
            int ct=cnt;
            if(a[i]==0)
            {
                if(v[i]>vm)
                {
                    cnt++;
                    h[cnt].l=d[i];
                    h[cnt].r=t;
                    h[cnt].kbl=h[cnt].kbr=1;
                }
            }
            if(a[i]>0)
            {
                if(v[i]<vm)
                {
                    double kk=(vm*vm-v[i]*v[i])*1.0/(2*a[i]*1.0);
                    if(kk+d[i]<t)
                    {
                        cnt++;
                        h[cnt].l=kk+d[i];
                        h[cnt].r=t;
                        h[cnt].kbl=0;
                        h[cnt].kbr=1;
                    }
                }
                if(v[i]==vm)
                {
                    cnt++;
                    h[cnt].l=d[i];
                    h[cnt].r=t;
                    h[cnt].kbl=0,h[cnt].kbr=1;
                }
                if(v[i]>vm)
                {
                    cnt++;
                    h[cnt].l=d[i];
                    h[cnt].r=t;
                    h[cnt].kbl=h[cnt].kbr=1;
                }
            }
            if(a[i]<0)
            {
                if(v[i]>vm)
                {
                    a[i]=-a[i];
                    double kk=(v[i]*v[i]-vm*vm)*1.0/(2*a[i]*1.0);
                    if(kk+d[i]-t<=ex)
                    {
                        cnt++;
                        h[cnt].l=d[i];
                        h[cnt].r=kk+d[i];
                        h[cnt].kbl=1;
                        h[cnt].kbr=0;
                    }
                    else
                    {
                        cnt++;
                        h[cnt].l=d[i];
                        h[cnt].r=t;
                        h[cnt].kbl=1;
                        h[cnt].kbr=1;
                    }
                }
            }
            if(ct!=cnt)
            {  
                int fl=0;
                for(int j=1;j<=m;j++)
                {
                    if((wp[j]-h[cnt].l>ex||(abs(wp[j]-h[cnt].l)<=ex&&h[cnt].kbl==1))&&(h[cnt].r-wp[j]>ex||(abs(h[cnt].r-wp[j])<=ex&&h[cnt].kbr==1)))
                    {
                        fl=1;
                        p[j]++;
                    }
                }
                if(fl==0)
                cnt--;
            }
        }
        cout<<cnt<<' ';
        sort(h+1,h+cnt+1,cmp);
        for(int i=1;i<=cnt;i++)
        {
            if(del[i]==0)
            {
                ans++;
                int wz,ma=0;
                for(int j=1;j<=m;j++)
                {
                    if(sy[j]==1)
                    continue;
                    double dl=wp[j]*1.0-h[i].l,dr=h[i].r-wp[j]*1.0;
                    if(ma<p[j]&&(dl>ex||(abs(dl)<=ex&&h[i].kbl==1))&&(dr>ex||(abs(dr)<=ex&&h[i].kbr==1)))
                    {
                        ma=p[j];
                        wz=j;
                    }
                }
                sy[wz]=1;
                for(int k=i;k<=cnt;k++)
                {
                    double dl=wp[wz]*1.0-h[k].l,dr=h[k].r-wp[wz]*1.0;
                    if((dl>ex||(abs(dl)<=ex&&h[k].kbl==1))&&(dr>ex||(abs(dr)<=ex&&h[k].kbr==1))&&del[k]==0)
                    {
                        del[k]=1;
                        for(int j=1;j<=m;j++)
                        {
                            if(sy[j]==1)
                            continue;
                            double dll=wp[j]*1.0-h[k].l,drr=h[k].r-wp[j]*1.0;
                            if((dll>ex||(abs(dll)<=ex&&h[k].kbl==1))&&(drr>ex||(abs(drr)<=ex&&h[k].kbr==1)))
                            p[j]--;
                        }
                    }
                }
            }
        }
        cout<<m-ans<<endl;
    }
    return 0;
}